using UnityEngine;
using System.Collections;

public class CharacterMove : MonoBehaviour {
public int moveSpeed = 140;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
		Vector3 moveDirection = Vector3.zero;
		Vector3 newPosition = Vector3.zero;
		
		if(Input.GetKey(KeyCode.LeftArrow)) moveDirection.x -= 1;
		if(Input.GetKey(KeyCode.RightArrow)) moveDirection.x += 1;
		if(Input.GetKey(KeyCode.DownArrow)) moveDirection.y -= 1;
		if(Input.GetKey(KeyCode.UpArrow)) moveDirection.y += 1;
		
		
		moveDirection = moveDirection * (moveSpeed * Time.deltaTime);
		newPosition = transform.position + moveDirection;
		newPosition.x = Mathf.Clamp(newPosition.x, -22, 235);
		newPosition.y = Mathf.Clamp(newPosition.y, -148, 43);
		transform.position = newPosition;
	}
}
